package com.efounder.core;

import static java.lang.Math.atan2;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;

/**
 *
 * GCJ02---->BD09坐标系
 * Created by meijun on 17-3-6.
 */

public class MapUtils {



    public static final  double x_pi = 3.14159265358979324 * 3000.0 / 180.0;

    /**
     * GCJ-02 转换为 BD-09标准
     * @param gg_lon    GCJ标准下的经度
     * @param gg_lat   GCJ标准下的纬度
     * @return   百度地图下的经纬度
     */
   public static double[] GCJ02_2_BD09(double gg_lon, double gg_lat)
    {
        double x = gg_lon, y = gg_lat;
        double z = sqrt(x * x + y * y) + 0.00002 * sin(y * x_pi);
        double theta = atan2(y, x) + 0.000003 * cos(x * x_pi);
        double bd_lon = z * cos(theta) + 0.0065;
        double bd_lat = z * sin(theta) + 0.006;
        double []  result = {bd_lon,bd_lat};
        return result;
    }


  /*  *//**
     * GCJ-02 转换为 BD-09标准
     * @param bd_lon    GCJ标准下的经度
     * @param bd_lat   GCJ标准下的纬度
     * @return  经纬度
     *//*
    void bd_decrypt(double bd_lat, double bd_lon)
    {
        double x = bd_lon - 0.0065, y = bd_lat - 0.006;
        double z = sqrt(x * x + y * y) - 0.00002 * sin(y * x_pi);
        double theta = atan2(y, x) - 0.000003 * cos(x * x_pi);
        gg_lon = z * cos(theta);
        gg_lat = z * sin(theta);
    }*/
}
